package com.miplus.ccrm.common;

public class JUsrPerm {
    public static String DISSTAR_PHN="disstar.phone";
    public static String DISSTAR_IDNO="disstar.idno";
    public static String DISSTAR_CARD="disstar.cardno";

    public static String VIEW_ALLORGIN="view.allorgin";
    public static String VIEW_ALLFICASE="view.allficase";

    public static String CASE_ADMIN="case.admin";

    public static boolean hasPermission(JSysUser user,String perm)
    {
        if(user==null) return false;
        if(JPubUtils.IsEmpty(user.getPermlist())){
            return false;
        }
        for(String p : user.getPermlist()){
            if(JPubUtils.IsEqual(p,perm)){
                return true;
            }
        }
        return false;
    }

    public static String getPermission(JSysUser user,String perm)
    {
        if(user==null) return "";
        if(JPubUtils.IsEmpty(user.getPermlist())){
            return "";
        }
        for(String p : user.getPermlist()){
            if(JPubUtils.IsEqual(p,perm)){
                return perm;
            }
        }
        return "";
    }

    public static boolean viewAllFiCase(JSysUser user)
    {
        if(user==null) return false;

        if(JPubUtils.IsEmpty(user.getPermlist())){
            return false;
        }
        for(String p : user.getPermlist()){
            if(JPubUtils.IsEqual(p,VIEW_ALLFICASE)){
                return true;
            }
        }
        return false;
    }
}
